package com.clearliang.upcloudframe;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;

/**
 * 测试用例
 * */

public class MainActivity extends AppCompatActivity {

    private ImageView iv1;
    private Button btn1;
    private Button btn2;
    private Button btn3;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        initView();

        UpCouldUtil.getInstance().initUpCloud(this);

        initBtn1();
        initBtn2();
        initBtn3();

    }

    private void initBtn3() {
        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "本地视频路径";//测试
                UpCouldUtil.getInstance().videoUpload(url).setVideoUpLoadListener(new UpCouldUtil.OnVideoListener() {
                    @Override
                    public void successed(String originUrl, String modifyUrl) {
                        Log.e("原视频地址：",originUrl);
                        Log.e("修改视频地址：",modifyUrl);
                    }

                    @Override
                    public void failed() {

                    }
                });
            }
        });
    }

    private void initBtn2() {
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                UpCouldUtilExtra.getInstance(MainActivity.this).upLoad2Could("http://pic37.nipic.com/20140113/8800276_184927469000_2.png",iv1);
                UpCouldUtilExtra.getInstance(MainActivity.this).setUpLoadListener(new UpCouldUtilExtra.UpImageSuccess() {
                    @Override
                    public void successed(String url) {
                        Toast.makeText(MainActivity.this,url,Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void failed(String msg) {

                    }
                });
            }
        });
    }

    private void initBtn1() {
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url = "本地图片路径";//测试

                UpCouldUtil.getInstance().imageUpload(url).setImageUpLoadListener(new UpCouldUtil.OnImageListener() {
                    @Override
                    public void successed(String url) {
                        Log.e("又拍云地址：",url);
                        Toast.makeText(MainActivity.this,url,Toast.LENGTH_LONG).show();
                    }

                    @Override
                    public void failed() {

                    }
                });
            }
        });
    }

    private void initView() {
        iv1 = (ImageView) findViewById(R.id.iv_1);
        btn1 = (Button) findViewById(R.id.btn_1);
        btn2 = (Button) findViewById(R.id.btn_2);
        btn3 = (Button) findViewById(R.id.btn_3);
    }

}
